package refletion;

/**
 * @program: thread
 * @description:
 * @author: gongj
 * @Description: TODO
 * @create: 2020-06-04 21:08
 **/
public class Test4 {
    public static void main(String[] args) throws ClassNotFoundException {
        //主动引用
        //Son son = new Son();
        //son.testS();
       // Class.forName("refletion.Test4");

        //被动引用
       System.out.println(Son.d);
    }
}

class Father{
    static int a = 100;
    static final int b = 200;
    static {
        System.out.println("父类静态代码块执行:" + "a=" + a + "===b=" + b);
    }

    public Father() {
        a = 500;
        System.out.println("父类无参构造执行" + "a=" + a + "====b" + b);
    }

    public void testF(){
        a = 1000;
        System.out.println("父类方法执行" + "a==" + a + "===b=" + b);
    }
}

class Son extends  Father{
    static int d = 40;
    static final int c = 60;

    static {
        System.out.println("子类静态代码块执行:" + "a=" + a + "===b=" + b + "===d=" + d + "==c=" + c);
    }

    public Son() {
        a = 100;
        System.out.println("子类无参构造执行" + "a=" + a + "===b=" + b + "===d=" + d + "==c=" + c);
    }

    public void testS(){
        a = 1000;
        d = 500;
        System.out.println("子类方法执行" + "a=" + a + "===b=" + b + "d==" + d + "c===" + c);
    }
}